package com.itheima.test;

public class Test8 {
    public static void main(String[] args) {
        //需求：定义一个方法copyOfRange(int[] arr,int from,int to)
        //功能：将数组arr中从索引from(包含from)开始，到索引to(不包含to)结束的元素复制到新数组中，将新数组返回
        int[] arr = {1,2,3,4,5,6,7,8,9,10};
        int[] newarr = copyOfRange(arr,3,7);
        for (int i = 0; i < newarr.length; i++) {
            System.out.print(newarr[i] + " ");
        }
    }
    public static int[] copyOfRange(int[] arr,int from,int to){
        int[] newarr = new int[to - from];
        for (int i = 0; i < newarr.length; i++) {
            newarr[i] = arr[from++];
        }
        return newarr;
    }
}
